package webmarket.model;

import java.io.Serializable;
import javax.persistence.*;
import java.sql.Timestamp;
import java.util.List;


/**
 * The persistent class for the users database table.
 * 
 */
@Entity
@Table(name="users")
@NamedQuery(name="User.findAll", query="SELECT u FROM User u")
public class User implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	private int id;

	private boolean active;

	private String address;

	private String city;

	private String firstname;

	private Timestamp lastlogin;

	private String lastname;

	private int money;

	private String password;

	private Timestamp registered;

	private String role;

	@OrderColumn
	private String username;

	//bi-directional many-to-one association to ReadLog
	@OneToMany(mappedBy="user")
	private List<ReadLog> logs;

	//bi-directional many-to-one association to Merchandise
	@OneToMany(mappedBy="user")
	private List<Merchandise> merchandises;

	public User() {
	}

	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public boolean getActive() {
		return this.active;
	}

	public void setActive(boolean active) {
		this.active = active;
	}

	public String getAddress() {
		return this.address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getCity() {
		return this.city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getFirstname() {
		return this.firstname;
	}

	public void setFirstname(String firstname) {
		this.firstname = firstname;
	}

	public Timestamp getLastlogin() {
		return this.lastlogin;
	}

	public void setLastlogin(Timestamp lastlogin) {
		this.lastlogin = lastlogin;
	}

	public String getLastname() {
		return this.lastname;
	}

	public void setLastname(String lastname) {
		this.lastname = lastname;
	}

	public int getMoney() {
		return this.money;
	}

	public void setMoney(int money) {
		this.money = money;
	}

	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Timestamp getRegistered() {
		return this.registered;
	}

	public void setRegistered(Timestamp registered) {
		this.registered = registered;
	}

	public String getRole() {
		return this.role;
	}

	public void setRole(String role) {
		this.role = role;
	}

	public String getUsername() {
		return this.username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public List<ReadLog> getLogs() {
		return this.logs;
	}

	public void setLogs(List<ReadLog> logs) {
		this.logs = logs;
	}

	public ReadLog addLog(ReadLog log) {
		getLogs().add(log);
		log.setUser(this);

		return log;
	}

	public ReadLog removeLog(ReadLog log) {
		getLogs().remove(log);
		log.setUser(null);

		return log;
	}

	public List<Merchandise> getMerchandises() {
		return this.merchandises;
	}

	public void setMerchandises(List<Merchandise> merchandises) {
		this.merchandises = merchandises;
	}

	public Merchandise addMerchandis(Merchandise merchandis) {
		getMerchandises().add(merchandis);
		merchandis.setUser(this);

		return merchandis;
	}

	public Merchandise removeMerchandis(Merchandise merchandis) {
		getMerchandises().remove(merchandis);
		merchandis.setUser(null);

		return merchandis;
	}

}